package com.hhh.demo.sx.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.joda.time.DateTime;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    //mp执行添加操作，该方法执行
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("date",new DateTime().toString("yyyy-MM-dd hh:mm:ss"),metaObject);
    }

    //mp执行修改操作，该方法执行
    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("date",new DateTime().toString("yyyy-MM-dd hh:mm:ss"),metaObject);
    }
}
